package com.Shiro;

import com.Login.Service.LoginService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;



/**
 * Created by XingYang on 2019/3/11.
 */

//使用该类从数据库读取权限配置信息
public class FilterChainDefinitionMapBuilder {
        @Autowired
        LoginService loginService;

        private static Logger logger = Logger.getLogger(FilterChainDefinitionMapBuilder.class);
    public LinkedHashMap<String, String> buildFilterChainDefinitionMap(){
        logger.info("开始加载权限配置信息");
        LinkedHashMap<String,String> map = new LinkedHashMap<>();
        List<Map<String,String>> list = loginService.getPermissionConfig();

        for (Map<String,String> config:list){
            map.put(config.get("url"),config.get("auth"));
        }
        System.out.println(map.toString());
        logger.info("权限配置信息加载结束");

        return map;
    }


}
